package com.tg.base.date;

import org.junit.Assert;
import org.junit.Test;

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * Created by linzc on 2017/6/19.
 */
public class DateTest {
    @Test
    public void getStartTimeOfMonthTest() {
        Date date = DateUtils.getStartTimeOfMonth(new Date());

        Calendar day = Calendar.getInstance();
        day.setTime(date);
        System.out.println(date);
        Assert.assertTrue(day.get(Calendar.DAY_OF_MONTH) == 1);
    }

    @Test
    public void getEndTimeOfMonthTest() {
        Date date = DateUtils.getEndTimeOfMonth(new Date());

        Calendar day = Calendar.getInstance();
        day.setTime(date);
        System.out.println(date);
        Assert.assertTrue(day.get(Calendar.DAY_OF_MONTH) == 30);
    }

    @Test
    public void getEndTimeOfWeek() {
        Locale.setDefault(Locale.FRANCE);

        Date now = new Date();
        Date startTimeOfWeek = DateUtils.getStartTimeOfWeek(now, true);
        Date endTimeOfWeek = DateUtils.getEndTimeOfWeek(now);

        System.out.println(startTimeOfWeek);
        System.out.println(endTimeOfWeek);
    }
}
